package com.humanSource.code.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.humanSource.code.entity.DepCategoryEntity;
import com.humanSource.code.service.DepCategoryService;
import com.utils.PageUtils;
import com.utils.R;



/**
 * 部门三级分类
 *
 * @author mordenx
 * @email #####
 * @date 2021-07-12 21:10:54
 */
@RestController
@RequestMapping("code/depcategory")
public class DepCategoryController {
    @Autowired
    private DepCategoryService depCategoryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
        public R list(@RequestParam Map<String, Object> params){
        PageUtils page = depCategoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
       public R info(@PathVariable("id") Long id){
		DepCategoryEntity depCategory = depCategoryService.getById(id);

        return R.ok().put("depCategory", depCategory);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
       public R save(@RequestBody DepCategoryEntity depCategory){
		depCategoryService.save(depCategory);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
        public R update(@RequestBody DepCategoryEntity depCategory){
		depCategoryService.updateById(depCategory);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
        public R delete(@RequestBody Long[] ids){
		depCategoryService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
